package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.material.domain.UserData;
import com.ruoyi.material.domain.WeekData;
import com.ruoyi.material.service.ISysMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;

import java.util.List;

/**
 * 首页
 *
 * @author ruoyi
 */
@RestController
public class SysIndexController
{
    /** 系统基础配置 */
    @Autowired
    private RuoYiConfig ruoyiConfig;

    @Autowired
    private ISysMaterialService sysMaterialService;

    /**
     * 访问首页，提示语
     */
    @RequestMapping("/")
    public String index()
    {
        return StringUtils.format("欢迎使用{}后台管理框架，当前版本：v{}，请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
    }

    @GetMapping("getUserData")
    public AjaxResult getUserData(){
        AjaxResult ajax = AjaxResult.success();
        UserData userData = sysMaterialService.getUserData();
        return ajax.put("userData",userData);
    }

    @GetMapping("getWeekData")
    public AjaxResult getWeekData(){
        AjaxResult ajax = AjaxResult.success();
        List<WeekData> weekData = sysMaterialService.getWeekData();
        return ajax.put("weekData",weekData);
    }
}
